package com.wmx.www;

import com.google.common.collect.Lists;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wangMaoXiong
 * @version 1.0
 * @date 2020/12/29 15:16
 */
public class Wang {

    @Test
    public void test() {
        Map<String, Object> dataMap = new HashMap<>();
        dataMap.put("code", 200);
        Map<String, Object> dataMap2 = new HashMap<>();
        dataMap2.put("code", 500);

        List<Map<String, Object>> dataList = new ArrayList<>();
        dataList.add(dataMap);
        dataList.add(dataMap2);

        check1(dataList);

        System.out.println(dataList);
    }

    public void check1(List<Map<String, Object>> dataList) {
        for (Map<String, Object> map : dataList) {
            check2(Lists.newArrayList(map));
        }
    }

    public void check2(List<Map<String, Object>> dataList) {
        for (Map<String, Object> map : dataList) {
            if ("500".equals(map.get("code") + "")) {
                map.put("error", "姓名不能为空");
            }
        }
    }


}
